<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 2017/6/17
 * Time: 15:07
 */

namespace Weixin\Service;


use Common\Common\Service;
use Weixin\Component\Cookie\CookieComponent;
use Weixin\Exception\WeixinException;
use Weixin\Response\GetCookieResponse;

class GetCookieService implements Service
{
    public function run()
    {
        $response = new GetCookieResponse();
        $component = new CookieComponent();
        try {
            $result = $component->getCookie();
            if (is_null($result) == true) {
                $response->setItIsNull();
            } else {
                $response->setOpenId($result);
            }
        } catch (WeixinException $e) {
            throw new WeixinException($e->getMessage(), $e->getCode());
        }
        return $response;
    }
}